package com.fy.fyai.service.downloaddecorator.enums;

import java.util.Arrays;

/**
 * @author fwq
 * @description 用户类型枚举
 * @date 2025-11-03 18:54
 */
public enum UserTypeEnum {
    /**
     * 普通用户
     */
    NORMAL("normal", "普通用户"),
    /**
     * VIP用户
     */
    VIP("vip", "VIP用户"),
    /**
     * SVIP用户
     */
    SVIP("svip", "SVIP用户");

    private final String code;
    private final String info;

    UserTypeEnum(String code, String info) {
        this.code = code;
        this.info = info;
    }

    public String getCode() {
        return code;
    }

    public String getInfo() {
        return info;
    }

    /**
     * 根据code获取枚举
     *
     * @param code 枚举code
     * @return 对应的枚举值，找不到返回null
     */
    public static UserTypeEnum getByCode(String code) {
        return Arrays.stream(values())
                .filter(e -> e.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }
}
